package com.yimi.yinhepda.db.table;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.yimi.yinhepda.entity.response.StorageDetail;
import com.yimi.yinhepda.entity.response.StorageInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author user
 * @date 2017/4/12
 * 库区基础资料
 */
@DatabaseTable(tableName = "storageInfoTable")
public class StorageInfoTable {
    @DatabaseField(generatedId = true)
    private transient Long id;
    @DatabaseField(uniqueIndex = true)
    private String storageId;
    @DatabaseField
    private int storageType;
    /**
     * 库区编码
     */
    @DatabaseField(index = true)
    private String storageCode;
    /**
     * 所属分拨
     */
    @DatabaseField
    private String deptCode;
    /**
     * 库区名称
     */
    @DatabaseField
    private String storageName;
    @DatabaseField
    private String placeName;
    @DatabaseField
    private String remark;
    /**
     * 公司编号
     */
    @DatabaseField
    private String compCode;
    @DatabaseField
    private String creater;
    @DatabaseField
    private String createrTime;
    @DatabaseField
    private String modifier;
    @DatabaseField
    private String modifierTime;
    @DatabaseField
    private Integer isDelete;
    @DatabaseField
    private int recordVersion;
    @DatabaseField
    private String nextCode;
    @DatabaseField(index = true)
    private String lastTime;

    public StorageInfoTable(String storageId, int storageType, String storageCode, String deptCode, String storageName, String placeName, String remark,
                            String compCode, String creater, String createrTime, String modifier, String modifierTime, Integer isDelete, int recordVersion, String nextCode,
                            String lastTime) {
        this.storageId = storageId;
        this.storageType = storageType;
        this.storageCode = storageCode;
        this.deptCode = deptCode;
        this.storageName = storageName;
        this.placeName = placeName;
        this.remark = remark;
        this.compCode = compCode;
        this.creater = creater;
        this.createrTime = createrTime;
        this.modifier = modifier;
        this.modifierTime = modifierTime;
        this.isDelete = isDelete;
        this.recordVersion = recordVersion;
        this.nextCode = nextCode;
        this.lastTime = lastTime;
    }

    public String getLastTime() {
        return lastTime;
    }

    public void setLastTime(String lastTime) {
        this.lastTime = lastTime;
    }

    public StorageInfoTable() {
    }

    public String getStorageId() {
        return storageId;
    }

    public void setStorageId(String storageId) {
        this.storageId = storageId;
    }

    public int getStorageType() {
        return storageType;
    }

    public void setStorageType(int storageType) {
        this.storageType = storageType;
    }

    public String getStorageCode() {
        return storageCode;
    }

    public void setStorageCode(String storageCode) {
        this.storageCode = storageCode;
    }

    public String getDeptCode() {
        return deptCode;
    }

    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }

    public String getStorageName() {
        return storageName;
    }

    public void setStorageName(String storageName) {
        this.storageName = storageName;
    }

    public String getPlaceName() {
        return placeName;
    }

    public void setPlaceName(String placeName) {
        this.placeName = placeName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCompCode() {
        return compCode;
    }

    public void setCompCode(String compCode) {
        this.compCode = compCode;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getCreaterTime() {
        return createrTime;
    }

    public void setCreaterTime(String createrTime) {
        this.createrTime = createrTime;
    }

    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    public String getModifierTime() {
        return modifierTime;
    }

    public void setModifierTime(String modifierTime) {
        this.modifierTime = modifierTime;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public int getRecordVersion() {
        return recordVersion;
    }

    public void setRecordVersion(int recordVersion) {
        this.recordVersion = recordVersion;
    }

    public String getNextCode() {
        return nextCode;
    }

    public void setNextCode(String nextCode) {
        this.nextCode = nextCode;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public static List<StorageInfoTable> parse(List<StorageInfo> list) {
        if (list != null && list.size() > 0) {
            List<StorageInfoTable> tableList = new ArrayList<StorageInfoTable>();
            for (StorageInfo item : list) {
                if (item.getStorageDetailList() != null && item.getStorageDetailList().size() > 0) {
                    for (StorageDetail item1 : item.getStorageDetailList()) {
                        StorageInfoTable mStorageInfoTable =
                                new StorageInfoTable(item.getStorage_id(), item.getStorage_type(), item.getStorage_code(), item.getDept_code(),
                                        item.getStorage_name(), item.getPlace_name(), item.getRemark(), item.getComp_code(), item.getCreater(), item.getCreater_time(),
                                        item.getModifier(), item.getModifier_time(), item.getIs_delete(), item.getRecord_version(), item1.getNext_code(),
                                        item.getLatest_time());
                        tableList.add(mStorageInfoTable);
                    }
                }
            }
            return tableList;
        } else {
            return null;
        }
    }
}
